package com.itheima.customer.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="cst_customer")
public class Customer implements Serializable {

	@Id
	@Column(name="cust_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long custId;
	
	@Column(name="cust_name")
	private String custName;
	
	@Column(name="cust_industry")
	private String custIndustry;
	
	@Column(name="cust_address")
	private String custAddress;
	
	@Column(name="cust_phone")
	private String custPhone;
	
	@OneToMany(targetEntity=LinkMan.class,mappedBy="customer")
	private Set<LinkMan> linkMan = new HashSet<LinkMan>(0);
	
	//多对一关系映射：多个客户对应一个来源
	@ManyToOne(targetEntity=BaseDict.class)
	@JoinColumn(name="cust_source",referencedColumnName="dict_id")
	private BaseDict custSourceBaseDict;
	

	//多对一关系映射：多个客户对应一个级别
	@ManyToOne(targetEntity=BaseDict.class)
	@JoinColumn(name="cust_level",referencedColumnName="dict_id")
	private BaseDict custLevelBaseDict;
	
	
	
	public Customer() {
	}
	//加上了有参构造必须,提供无参构造
	public Customer(Long custId, String custName) {
		super();
		this.custId = custId;
		this.custName = custName;
	}
	public Long getCustId() {
		return custId;
	}
	public void setCustId(Long custId) {
		this.custId = custId;
	}
	public String getCustName() {
		return custName;
	}
	public void setCustName(String custName) {
		this.custName = custName;
	}
	
	public BaseDict getCustSourceBaseDict() {
		return custSourceBaseDict;
	}
	public void setCustSourceBaseDict(BaseDict custSourceBaseDict) {
		this.custSourceBaseDict = custSourceBaseDict;
	}
	public BaseDict getCustLevelBaseDict() {
		return custLevelBaseDict;
	}
	public void setCustLevelBaseDict(BaseDict custLevelBaseDict) {
		this.custLevelBaseDict = custLevelBaseDict;
	}
	public String getCustIndustry() {
		return custIndustry;
	}
	public void setCustIndustry(String custIndustry) {
		this.custIndustry = custIndustry;
	}

	public String getCustAddress() {
		return custAddress;
	}
	public void setCustAddress(String custAddress) {
		this.custAddress = custAddress;
	}
	public String getCustPhone() {
		return custPhone;
	}
	public void setCustPhone(String custPhone) {
		this.custPhone = custPhone;
	}
	@Override
	public String toString() {
		return "Customer [custId=" + custId + ", custName=" + custName + ", custIndustry=" + custIndustry
				+ ", custSourceBaseDict=" + custSourceBaseDict + ", custLevelBaseDict=" + custLevelBaseDict
				+ ", custAddress=" + custAddress + ", custPhone=" + custPhone + "]";
	}

	
	
	
}
